package com.shangqing.document_management.service.serviceImpl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.shangqing.document_management.entity.User;
import com.shangqing.document_management.mapper.AdminMapper;
import com.shangqing.document_management.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
@Transactional
@Service
public class AdminServiceImpl implements AdminService {
    @Autowired
    AdminMapper adminMapper;
    @Override
    public User selectUserByName(String username) {
        User user=adminMapper.selectUserByUserName(username);
        return user;
    }

    @Override
    public PageInfo findAll(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<User> list=adminMapper.findAll();
        PageInfo pageInfo=new PageInfo(list);
        return pageInfo;
    }

    @Override
    public Boolean addUser(User user) {
        int i=adminMapper.addUser(user);
        if(i>0){
            return true;
        }
        return false;
    }

    @Override
    public User selectUserById(Integer id) {
        return adminMapper.selectUserById(id);
    }
}
